using System;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using PickGold.Charting.Data;

namespace PickGold.Charting
{
	internal class SeriesNameConverter : StringConverter
	{
		public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
		{
			DataManager manager = null;
			ArrayList values = new ArrayList();
			if ((context != null) && (context.Instance != null))
			{
				MethodInfo method = context.Instance.GetType().GetMethod("GetService");
				if (method != null)
				{
					object[] parameters = new object[] { typeof(DataManager) };
					manager = (DataManager)method.Invoke(context.Instance, parameters);
				}
				if (manager == null)
				{
					throw new InvalidOperationException(SR.ExceptionEditorChartTypeRegistryServiceInObjectInaccessible(context.Instance.GetType().ToString()));
				}
				foreach (Series series in manager.Series)
				{
					values.Add(series.Name);
				}
			}
			return new TypeConverter.StandardValuesCollection(values);
		}

		public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
		{
			return false;
		}

		public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
		{
			return true;
		}
	}
}

